package com.jd.cmdb.tsc.service;

import com.jd.cmdb.tsc.entity.Task;
import com.jd.cmdb.tsc.processor.IProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by tianzhengguo on 2016/1/11.
 */
@Service("processorService")
public class ProcessorServiceImpl implements ProcessorService<Task> {

    public static final Logger logger = LoggerFactory.getLogger(ProcessorServiceImpl.class);

    @Resource
    private IProcessor processor;

    public void execute() throws Exception {
        List<Task> tasks = processor.selTasks();
        logger.info("任务数:{}", tasks.size());
        for (Task task : tasks) {
            processor.process(task);
        }
    }
}
